%======================================================================
%   lathesis.sty (Style file for Carleton University Theses)
%   Version: 3.0
%   Author:    Radha Valiveti (rsv@scs.carleton.ca).
%   History:
%      Based on the original style file by Mike Dunleavy (Aug 87).
%      Uses ideas contained in the style file "suthesis.sty".
%
%   Adapted for Bologna University by Riccardo Focardi (Lug 98)
%                              and by Marco Bernardo (Aug 98)
%                              and by Luca Padovani (Mar 02)
%                              and by Stefano Zacchiroli (Ott 06)
%======================================================================
% 
\typeout{Document style option `lathesis' <01 July 1992>.}
\newcommand{\comment}[1]{}

\comment{
======================================================================

Documentation:

    This style file modifies the standard report style to follow the
    Guidelines issued by the Graduate Studies and Research Office
    (GSRO) for the preparation of Doctoral and Master's theses.

    The \beforepreface command creates the title page, and a signature
    page.  By default, the style produces the signaturepage for a
    Ph.D. thesis. If you desire a M.Sc. signaturepage instead,
    simply add the command "\phdsignaturefalse" just before the
    "\beforepreface" command. Then the user should put preface
    section(s), using the \prefacesection{section title} command.
    The \afterpreface command then produces the table of contents
    list of tables and figures, and sets things up to start the main
    body (on arabic page 1).
    
    The following commands can control what goes in the front matter
    material:
    
	\title{thesis title}
	\author{author's name}
	\supervisor{the principal advisor's name}
        \chairman{Chairman's name}
	\submitdate{month year in which the thesis is submitted}

   Example of use:

    \documentstyle[12pt,lathesis, fleqn]{report}
    \title{How to Write Theses\\
 	    With Two Line Titles}
    \author{John Henry Candidate}
    \dept{author's department}
    \submitdate{month year in which submitted to GSRO}
    \supervisor{John Parker}
    \chairman{Chairman's name}

    \begin{document}
    \beforepreface
    \prefacesection{Abstract}
        This thesis tells you all you need to know about...
    \prefacesection{Acknowledgements}
        I would like to thank...
    \afterpreface
 
    \chapter{Introduction}
         ...
    \chapter{Conclusions}
         ...
    \appendix
    \chapter{A Long Proof}
         ...
    \bibliographystyle{plain}
    \bibliography{mybib}
    \end{document}

======================================================================
}

% First thing we do is make sure that report has been loaded.  A
% common error is to try to use suthesis as a documentstyle.

\@ifundefined{chapter}{\@latexerr{The `lathesis' option should be used
with the `report' document style}{You should probably read the
lathesis documentation.}}{}

% \author, \title are defined in report; here are the rest of the
% front matter defining macros

\def\dept#1{\gdef\@dept{#1}}
\def\degree#1{\gdef\@degree{#1}}
\def\prevdegree#1{\gdef\@prevdegree{#1}}
\def\supervisor#1{\gdef\@supervisor{#1}}
\def\chairman#1{\gdef\@chairman{#1}}
\def\submitdate#1{\gdef\@submitdate{#1}}
\def\reportdate#1{\gdef\@date{#1}}
\def\examdate#1{\gdef\@examdate{#1}}
\def\copyrightyear#1{\gdef\@copyrightyear{#1}}
\def\@title{}
\def\@author{}
\def\@prevdegree{}	%previous degrees
\def\@degree{Doctor of Philosophy}
\def\@institute{Ottawa-Carleton Institute for Computer Science}%
\def\@dept{School of Computer Science}
\def\@supervisor{}
\def\@chairman{}
\def\@submitdate{\today}
\def\@examdate{\today}
\def\@copyrightyear{\number\the\year}

% ======================================================================
% Macros to produce the front pages...
% ======================================================================

\def\frontp{%
   \thispagestyle{empty}            % Prevents page number & headers.
   \mbox{}\vspace{1cm}              % Adds space at top of page.
\begin{center}
                        {\LARGE\bf \@title}
                        \vskip 2cm
                        {\Large\bf
                                \def\and{%%% \begin{tabular} has already
started
                                        \end{tabular}\hskip 1em plus .17fil
                                        \begin{tabular}[t]{@{} c}}
                                \noindent
                                \begin{tabular}[t]{@{} c}\@author
                                \end{tabular}
                        }
                        \vskip 3cm
                        {\Large\bf \@reportname\ \@reportnumber} \\
                        \vskip 0.5cm
                        {\Large\rm\@date}
                \end{center}
                \vfill
                \begin{center}
                        {\Large
                                Department of Computer Science \\
                                University of Bologna \\
                                Mura Anteo Zamboni 7 \\
                                40127 Bologna (Italy)
                        }
                        \vspace*{1cm}
                \end{center}




\newpage
}

\def\titlepage{%
   \thispagestyle{empty}            % Prevents page number & headers.
                \null

{\fontfamily{ppl}\fontsize{9pt}{0pt}\fontshape{n}\selectfont
                \input{titles}
}
                
\newpage
\cleardoublepage
}
\def\titlep{%
   \thispagestyle{empty}            % Prevents page number & headers.
   \mbox{}\vspace{1cm}              % Adds space at top of page.
   \begin{center}
   	{\Large Dottorato di Ricerca in Informatica} \\
	{\large Universit\`a di Bologna e Padova} \\
{\large INF/01 INFORMATICA} \\
        {\large Ciclo XXII}\\
	\vspace{2cm}
       {\LARGE\bf\expandafter{\@title}}\\
       \vspace{10mm}
       {\Large\expandafter{\@author}}\\
       \vspace{10mm}
      \@submitdate\\
          \vspace{4cm}
\begin{tabular}{ccc}
Coordinatore: & ~~~~~~~~~~~~~~~~ & Tutore: \\
\@chairman & & \@supervisor \\
 & & \\
\rule{2in}{.5pt} & & \rule{2in}{.5pt}
\end{tabular}
%      \vspace*{2 cm}
%      \copyright~Copyright\\
%      \@copyrightyear, \@author
     \end{center}
\newpage
}

%
% The only difference between the Ph.D. signature page and the 
% M.Sc  signaturepage is that the former requires the signature 
% of the external examiner.
%
\newif\ifphdsignature
\phdsignaturetrue

\def\signaturepage{%
     \begin{center}
       The undersigned hereby recommend to\\
       The Faculty of Graduate Studies and Research\\
       acceptance of the thesis,\\
       {\bf\expandafter{\@title}}\\
       submitted by\\
       \@author, \@prevdegree\\
       in partial fulfilment of the requirements\\
       for the degree of \@degree\\
          \vspace{2.5cm}
          \rule{3in}{.5pt}\\
       \@chairmantitle, \@dept\\
          \vspace{2.5cm}
          \rule{3in}{.5pt}\\
       Thesis Supervisor\\
       \ifphdsignature
          \vspace{1cm}
       \else
%          \vspace{6cm}
	   \vspace{5cm}
       \fi
       Carleton University\\
       \@examdate
     \end{center}
\newpage
}


% ======================================================================
% The thesis normally starts with the command "\beforepreface".
% This has the effect of selecting roman pagenumbering, with the
% pagenumbers appearing at the bottom of the page. After the 
% front-matter (i.e. title, abstract, toc, etc) has been produced, 
% we switch to "afterpreface". Once we switch to this made, we
% go to slightly elaborate headings. Moreover, the first page of
% chapter does not contain a page number.
%======================================================================

\def\beforepreface{
        \flushbottom
        \huge\normalsize % change baselineskip
        \parskip=0pt plus 4.51pt
	\pagenumbering{roman}
%	\pagestyle{plain}
	\frontp
	\titlepage
	\titlep
%	\thispagestyle{empty}
	~~\newpage
%	\signaturepage
        \def\chapter{\frontchapter}
}

\def\prefacesection#1{%
	\chapter*{#1}
	\addcontentsline{toc}{chapter}{#1}
}

\def\afterpreface{%
	\newpage
	\tableofcontents
        \listoffloats
        \cleardoublepage
\dominitoc

%\thispagestyle{empty}
%\mbox{}
%\vfill
%\newpage

	\pagenumbering{arabic}
%	\pagestyle{headings}
        %\setlength{\textheight}{210 mm}
        %\def\chapter{\bodychapter}
}

% =====================================================================
% If you have other types of floats in the thesis, just redefine
% the commands "\listoffloats" and "\seplistoffloats".
% The first command generates the actual list of various floats.
% The command "seplistoffloats" is used to separate the list of 
% floats of one chapter from those of the previous one.
% =====================================================================

\newcommand{\listoffloats}{%
        %\cleardoublepage
        %\addcontentsline{toc}{chapter}{List of Tables}
        %\listoftables
        \cleardoublepage
        \addcontentsline{toc}{chapter}{List of Figures}
        \listoffigures
}

\newcommand{\seplistoffloats}{%
 \addtocontents{lof}{\protect\addvspace{10pt}}
 %\addtocontents{lot}{\protect\addvspace{10pt}}
}

% ======================================================================
%  Dimensions of the page
% ======================================================================

% \setlength{\textheight}{200 true mm}
% %\setlength{\textwidth}{6 true in}
% \setlength{\textwidth}{150 true mm}
% %\setlength{\oddsidemargin}{0.5 true in}   % may need to adjust these.
% \setlength{\oddsidemargin}{5 true mm}
% \setlength{\evensidemargin}{5 true mm}
% \setlength{\topmargin}{-1mm}

% =====================================================================
%  Linespacings...
% =====================================================================

\renewcommand{\baselinestretch}{1.4}
\newcommand{\singlespace}%
  {\renewcommand{\baselinestretch}{1.0}\huge\normalsize}
\newcommand{\doublespace}%
  {\renewcommand{\baselinestretch}{1.4}\huge\normalsize}

% =====================================================================
%  Change the definition of the Latex Macro '@arabic' so that it will
%  print out the number 0. This is useful if we want to print out the
%  number 0 (e.g. Theorem 0).
% =====================================================================

\def\@arabic#1{\ifnum #1 > -1 \number #1\fi}      % new def.

%======================================================================
%  Environments : theorem, lemma, proof, etc.
%  The optional argument to the definitions of these environments i.e.
%  [section] or [chapter] ensure that the appropriate counters are reset
%  at the begining of each chapter. Associated with each of these
%  environments, is a counter with the same name as the environment.
%  These counters are incremented just before they are used. In order to
%  begin the numbering of theorems with Theorem 0, include the following
%  line in the beg.  \addtocounter{theorem}{-1}
%======================================================================

% \newtheorem {lemma} {Lemma} [chapter]
% \newtheorem {proposition} {Proposition} [chapter]
% \newtheorem {theorem} {Theorem} [chapter]
% \newtheorem {conjecture} {Conjecture} [chapter]
% \newtheorem {property} {Property} [chapter]
% \newtheorem {corollary} {Corollary} [chapter]
% \newtheorem {definition} {Definition} [chapter]
% \newtheorem {requirement} {Requirement} [chapter]
% \newtheorem {aux_usecase} {Use case} [chapter]
% \newenvironment{usecase}[1][]{%
%  \begin{aux_usecase}{\it #1}\rm}{%
%  \vspace{-1em}\hfill$\boxempty$\end{aux_usecase}}
% \newtheorem {aux_example} {Example} [chapter]
% \newenvironment{example}[1][]{%
%  \begin{aux_example}{\it #1}\rm}{%
%  \vspace{-1em}\hfill$\boxempty$\end{aux_example}}
% \newtheorem {aux_exercise} {Exercise} [chapter]
% \newenvironment{exercise}[1][]{%
%  \begin{aux_exercise}{\it #1}\rm}{%
%  \vspace{-1em}\hfill$\boxempty$\end{aux_exercise}}
% %\newenvironment{equation*}{\[}{\]}
% \newenvironment{proof}{\noindent{\bf Proof:}\rm}{\hfill $\Box$\par}
% \newenvironment{miniproof}{\noindent{\bf Sketch of Proof:}\rm}{\hfill $\Box$\par}
% 
% \newtheorem {infrule} {Rule} [chapter]

% ======================================================================
% => Misc. stuff ...
% ======================================================================

\newcommand{\appref}[1]{Appendix~\ref{#1}}
\newcommand{\chapref}[1]{Chapter~\ref{#1}}
\newcommand{\corref}[1]{Corollary~\ref{#1}}
\newcommand{\defref}[1]{Definition~\ref{#1}}
%\newcommand{\eqref}[1]{Equation~(\ref{#1})}
\newcommand{\etal}{{\it et al.}\@ifnextchar,{}{\ }}
\newcommand{\exref}[1]{Example~\ref{#1}}
\newcommand{\figref}[1]{Figure~\ref{#1}}
\newcommand{\lemref}[1]{Lemma~\ref{#1}}
\newcommand{\proref}[1]{Property~\ref{#1}}
\newcommand{\reqref}[1]{Requirement~\ref{#1}}
\newcommand{\secref}[1]{Section~\ref{#1}}
\newcommand{\tabref}[1]{Table~\ref{#1}}
\newcommand{\theref}[1]{Theorem~\ref{#1}}

\newcommand\@reportnumber{ }
\newcommand\@reportname{ }

\newcommand\reportnumber[1]{
        \renewcommand\@reportname{Technical Report}
        \renewcommand\@reportnumber{{UBLCS}-{#1}}
}

% =======================================================================
%   Updates to report.sty (& rep12.sty)
%     In this style, we redefine the following commands which are 
%     originally defined in "rep12.sty":
%        chapter     @chapter
%        @makechapterhead     @makeschapterhead
% ========================================================================

\def\frontchapter{\cleardoublepage \thispagestyle{plain} \global\@topnum\z@
   \@afterindentfalse \secdef\@chapter\@schapter}

\def\bodychapter{\cleardoublepage \thispagestyle{empty} \global\@topnum\z@
   \@afterindentfalse \secdef\@chapter\@schapter}
 
 %\def\chapter{\frontchapter}  (done in \beforepreface)

\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
 \refstepcounter{chapter}
 \typeout{\@chapapp\space\thechapter.}
 \addcontentsline{toc}{chapter}{\protect
 \numberline{\thechapter}#1}\else
 \addcontentsline{toc}{chapter}{#1}\fi
 \chaptermark{#1}
 \seplistoffloats
 \if@twocolumn
    \@topnewpage[\@makechapterhead{#2}] 
 \else \@makechapterhead{#2}
    \@afterheading 
 \fi
}

\def\@schapter#1{\if@twocolumn \@topnewpage[\@makeschapterhead{#1}]
 \else \@makeschapterhead{#1} 
 \@afterheading\fi}

\def\@makechapterhead#1{ \vspace*{50pt} { \parindent 0pt \raggedright
 \ifnum \c@secnumdepth >\m@ne \Large\bf \@chapapp{} \thechapter \par
 \vskip 20pt \fi \LARGE \bf #1\par
 \nobreak \vskip 40pt } }

\def\@makeschapterhead#1{ \vspace*{50pt} { \parindent 0pt \raggedright
 \LARGE \bf #1\par
 \nobreak \vskip 40pt } }

%======================================================================
%  Change the title of ``Contents, List of Figures'' etc. to mixed
%  case, instead of all in UPPER CASE.(original definitions in
%  report.sty)
%======================================================================

\def\tableofcontents{\@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn
 \fi\chapter*{Contents\@mkboth{Contents}{Contents}}
 \@starttoc{toc}\if@restonecol\twocolumn\fi}

\def\listoffigures{\@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn
 \fi\chapter*{List of Figures\@mkboth
 {List of Figures}{List of Figures}}\@starttoc{lof}\if@restonecol
 \twocolumn\fi}

\def\listoftables{\@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn
 \fi\chapter*{List of Tables\@mkboth
 {List of Tables}{List of Tables}}\@starttoc{lot}\if@restonecol
 \twocolumn\fi}

\def\thebibliography#1{%
   %\chapter*{Bibliography\@mkboth{Bibliography}{Bibliography}}%
   \chapter*{References\@mkboth{References}{References}}
   %\addcontentsline{toc}{chapter}{Bibliography}%
   \addcontentsline{toc}{chapter}{References}
   \list{[\arabic{enumi}]}{\settowidth\labelwidth{[#1]}%
   \leftmargin\labelwidth
   \advance\leftmargin\labelsep
   \usecounter{enumi}}
   \def\newblock{\hskip .11em plus .33em minus .07em}
   \sloppy\clubpenalty4000\widowpenalty4000
   \sfcode`\.=1000\relax}


\def\fnum@figure{{\bf Figure \thefigure}}
\def\fnum@table{{\bf Table \thetable}}

%======================================================================
% Change the headings (make them appear like the headers in the 
% Latex book).
%======================================================================

% \if@twoside
%   \def\ps@headings{%
%      \let\@mkboth\markboth
%      \def\chaptermark##1{\markright {\ifnum \c@secnumdepth >\m@ne
%            \@chapapp\ \thechapter. \ \fi ##1}}
%      \def\@oddfoot{}\def\@evenfoot{}%
%      \def\@oddhead{\underline{\protect%
%         \makebox[\textwidth]{\sf \rightmark \hfill \thepage}}}%
%      \def\@evenhead{\underline{\protect%
%         \makebox[\textwidth]{\sf \thepage \hfill \rightmark}}}%
%   }%
% \else 
%    \def\ps@headings{
%        \let\@mkboth\markboth
%        \def\chaptermark##1{\markright {\ifnum \c@secnumdepth >\m@ne
%            \@chapapp\ \thechapter. \ \fi ##1}}
%        \def\@oddfoot{}\def\@evenfoot{}%
%        \def\@oddhead{\underline{\protect%
%          \makebox[\textwidth]{\bf \rightmark \hfill \thepage}}}
%    }
% \fi
\endinput
%
% End of 'lathesis.sty'

% vim: set ft=tex:
